<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑邮箱配置信息</title>
<link href="${rc.getContextPath()}/resources/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/jquery.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/common.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/jquery.validate.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/messages_cn.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/resources/js/input.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/js/ajaxupload.js"></script>
<script type="text/javascript" src="${rc.getContextPath()}/js/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript">
var base='${base!}';
var emailConfigId='${emailConfigId!}';
function goBack(){
	window.location.href=base+'/emailConfig/admin/seedEmailConfig.html?emailConfigId='+emailConfigId;
};
function saveEmailConfig() {
	var form1 = $("#tableForm");
	form1.submit();
};
function myAlert(txt) {
	window.parent.$.dialog({
		lock : true,
		content : txt,
		cancelVal : '确定',
		autoSize : true,
		cancel : function() { //请求成功后处理函数。 
		}
	});
}

jQuery.validator.addMethod("validEmailContent", function(value, element) {
	var content = element.innerHTML;//$("#txtEmailContent").html();
	if(content && content.indexOf("IdentifyCodeToReplace") > -1){
		return true;
	}else{
		return false;
	}
}, "请输入包含IdentifyCodeToReplace的内容，以便替换为真实的验证码供用户进行注册验证");

jQuery.validator.addMethod("validPassword", function(value, element) {		 
	if($("#txtPassword").val()== value){
		return true;
	}else{
		return false;
	}
}, "两次输入的密码不一致");

$(document).ready(function() {
	var $inputForm = $("#tableForm");
	$inputForm.validate({
		errorClass : "fieldError",
		rules : {
			emailPort : {required:true},
			emailServer : {required:true},
			emailFrom : {required:true},
			user : {required:true},
			password : {required:true},
			password2 : {required:true,validPassword:true},
			emailTitle : {required:true},
			emailContent : {required:true,validEmailContent:true}
		}
	});
	
	var errMsg = "${errMsg}";
	if (errMsg) {
		alert(errMsg);
	}
});
</script>
</head>
<body>
	<div class="path">
		<b>编辑邮箱配置信息</b>
	</div>
	<form action="${base!}/emailConfig/admin/updateEmailConfig.html" method="post" id="tableForm" name="tableForm" enctype="multipart/form-data">
		<input type="hidden" name='emailConfigId' value='${emailConfigId!}'/>
		<table class="input tabContent">
			<tbody>
				<tr>
					<th><span class="requiredField">*</span>smtp端口:</th>
					<td>
						<input type="text" name="emailPort" value="${emailConfig.emailPort!}"/>（默认：25）
					</td>
					<th><span class="requiredField">*</span>服务器地址:</th>
					<td>
						<input type="text" name="emailServer" value="${emailConfig.emailServer!}"/>（例如：smtp.163.com）
					</td>
				</tr>
				<tr>
					<th><span class="requiredField">*</span>发送者:</th>
					<td>
						<input type="text" name="emailFrom" value="${emailConfig.emailFrom!}"/>（例如：lunaxyz@163.com）
					</td>
					<th><span class="requiredField">*</span>发送者地址:</th>
					<td>
						<input type="text" name="user" value="${emailConfig.user!}"/>（例如：lunaxyz@163.com）
					</td>
				</tr>
				<tr>
					<th><span class="requiredField">*</span>邮箱密码:</th>
					<td>
						<input type="password" name="password" id="txtPassword" value="${emailConfig.password!}"/>
					</td>
					<th><span class="requiredField">*</span>确认密码:</th>
					<td>
						<input type="password" name="password2" value="${emailConfig.password!}"/>
					</td>
				</tr>
				<tr>
					<th><span class="requiredField">*</span>邮箱验证反馈标题:</th>
					<td colspan="3"><input type="text" name="emailTitle" style="width:500px" value="${emailConfig.emailTitle}"/></td>
				</tr>
				<tr>
					<th><span class="requiredField">*</span>邮箱验证反馈内容:</th>
					<td colspan="3">
						<table width="100%" height="100%">
							<tr align="left">
								<td width="360px">
									<textarea name="emailContent" id="txtEmailContent" cols="60" rows="6">${emailConfig.emailContent}</textarea>
								</td>
								<td>
									使用说明：<br />
									例如反馈内容为：您的验证码是：<font color="red">121313</font> <br />
									那么请输入内容：您的验证码是：<font color="red">IdentifyCodeToReplace</font> <br />
									其中：发邮件给用户的时候，IdentifyCodeToReplace会被替换为真实的验证码
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</tbody>
		</table>

		<table class="input">
			<colgroup>
				<col width="15%" />
				<col width="35%" />
				<col width="15%" />
				<col width="35%" />
			</colgroup>
			<tr>
				<td></td>
				<td colspan="3">
					<input type="button" class="button" value="保存" onclick='saveEmailConfig()'/> 
					<input type="button" class="button" value="返回" onclick="goBack()" />
				</td>
			</tr>			
		</table>
	</form>
</body>
</html>